<?php 

	function qiuhe($x)
	{
		$num = 0;
		for ($i=0; $i < $x ; $i++) { 
			$num += $i;
		}
		return $num;
	}

$res = qiuhe(1000);

var_dump($res);

	function timeCt($time)
	{
		$diff = time()-$time;
		if ($diff<60) {
			return "刚刚";
		}
		elseif ($diff<3600) {
			return round($diff/60)."分钟之前";
		}
		elseif ($diff<86400) {
			return round($diff/3600)."小时之前";
		}
		elseif ($diff<(86400*7)) {
			return round($diff/86400)."天之前";
		}
		else {
			return date('Y-m-d H:i:s');
		}
	}

	$times = strtotime('2017-03-01');

	$timeres = timeCt($times);

	var_dump($timeres);


 ?>